from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
    # (notes on the url dispatcher from the django site show how to do this)
    # @note: (by ep) i don't think that we can avoid the repetition here without building a dispatcher
    # and i don't expect a dispatcher to play well with fastcgi. the purpose of this file w/ django
    # or the lighttpd config file with fastcgi is to let the server (django/lighttpd) be the dispatcher
    (r'^chord/get_predecessor',     'jackson.chord.views.server.get_predecessor_handler'),
    (r'^chord/get_successor',       'jackson.chord.views.server.get_successor_handler'),
    (r'^chord/is_predecessor',      'jackson.chord.views.server.is_predecessor_handler'),
    (r'^chord/join',                'jackson.chord.views.server.join_handler'),
    (r'^chord/closest_preceding_finger','jackson.chord.views.server.closest_preceding_finger_handler'),
    (r'^chord/leave',               'jackson.chord.views.server.leave_handler'),
    (r'^chord/notify',              'jackson.chord.views.server.notify_handler'),
    (r'^chord/stabilize',           'jackson.chord.views.server.stabilize_handler'),
    (r'^chord/update_successor',    'jackson.chord.views.server.update_successor_handler'),
    
    (r'^chord/admin/join_ring@(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(?P<port>\d+)',   
                                    'jackson.chord.views.admin.join_ring_handler'),
    (r'^chord/admin/init_ring',     'jackson.chord.views.admin.init_ring_handler'),
    (r'^chord/admin/leave_ring',    'jackson.chord.views.admin.leave_ring_handler'),
    (r'^chord/admin/whoami',        'jackson.chord.views.admin.whoami_handler'),
    (r'^chord/admin/lookup/(?P<key>.*)', 'jackson.chord.views.admin.lookup_handler'),
    
    ### Below added by ep
    #@contact: ep
    (r'^cdn/sync/clean',        'jackson.cdn.views.sync.clean_content_handler'),
    (r'^cdn/sync/poke',         'jackson.cdn.views.sync.poke_content_handler'),
    (r'^cdn/sync/collect',      'jackson.cdn.views.sync.collect_content_handler'),
    (r'^cdn/delegate_keys',     'jackson.cdn.views.server.delegate_keys_handler'),
    (r'^cdn/confirm_distribution',  'jackson.cdn.views.server.confirm_distribution_handler'),
    
    (r'^cdn/admin/dump_content_entry',
                                'jackson.cdn.views.admin.dump_content_table_handler'),
    (r'^cdn/admin/init_net',    'jackson.cdn.views.admin.init_net_handler'),
    (r'^cdn/admin/join_net@(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(?P<port>\d+)',   
                                'jackson.cdn.views.admin.join_net_handler'),
    (r'^cdn/admin/leave_net',   'jackson.cdn.views.admin.leave_net_handler'),
    (r'^cdn/admin/whoami',      'jackson.cdn.views.admin.whoami_handler'),
    
    (r'^cdn/client/upload',     'jackson.cdn.views.client.register_key_handler'),
    (r'^cdn/client/get_url',    'jackson.cdn.views.client.get_url_handler'),
    
    # rttopt patterns
    # @todo: add these
    # @todo: add some init/leave/join stuff
    (r'^rttopt/lookup',         'jackson.rttopt.views.lookup_handler'),
    (r'^rttopt/update',         'jackson.rttopt.views.update_handler'),
    (r'^rttopt/timer$',          'jackson.rttopt.views.timer'),
    (r'^rttopt/leave$',          'jackson.rttopt.views.leave_handler'),
    (r'^rttopt/admin/leave$',    'jackson.rttopt.views.leave_net'),
    
    
    # client views
    # these will probably redirect to the highest level module (rttopt here, cdn before)
    (r'^sup$',                   'jackson.rttopt.views.timer'),
    (r'^download$',              'jackson.rttopt.views.timer'), 
    (r'^upload$',                'jackson.rttopt.views.timer'),
    (r'^rttopt/ip_dump$',                'jackson.rttopt.views.dump_handler'),
    
    (r'^$', 'jackson.views.sup'),
)
